#@adminLayout() 

#define main() ### isAdd 表示创建，isEdit 表示修改 

#set(isAdd =doc == null ? true : false, isEdit = !isAdd)

<div class="jfa-header-box" id="jfa-header-box">
	<div class="jfa-crumbs" id="jfa-crumbs">文档管理 / #(isAdd ? "创建" :
		"修改")</div>
	<div class="jfa-search-box"></div>
	#include("/_view/_admin/common/_header_right.html")
</div>

### 内容区域
<div class="jfa-content-box" id="jfa-content-box">
	<div class="jfa-content" id="jfa-content">
		<form class="clearfix margin-top-25" id="myArticleForm"
			action="/admin/doc/#(isAdd ? 'save' : 'update')" method="post">

			#if (isEdit) <input name="oldMainMenu" type="hidden"
				value="#(doc.mainMenu)"> <input name="oldSubMenu"
				type="hidden" value="#(doc.subMenu)"> #end

			<div class="form-group margin-bottom-20">
				<label>主菜单</label> <input type="text" class="form-control"
					name="doc.mainMenu" value="#(doc.mainMenu??)" placeholder="直接填写序号" />
			</div>

			<div class="form-group margin-bottom-20">
				<label>子菜单</label> <input type="text" class="form-control"
					name="doc.subMenu" value="#(doc.subMenu??)" placeholder="一级菜单填写 0" />
			</div>

			<div class="form-group margin-bottom-20">
				<label>文档标题</label> <input type="text" class="form-control"
					name="doc.title" value="#(doc.title??)" placeholder="文档文章标题" />
			</div>

			<div class="form-group margin-bottom-20">
				<label>文档内容</label>
				<div>
					<script id="container" name="doc.content"
						style="line-height: 20px;" type="text/plain">#(doc.content??)</script>
				</div>
			</div>

			<div class="pull-right margin-bottom-20">
				#set(publishNo = com.jfinal.club.common.model.Document::PUBLISH_NO)
				#set(publishYes =
				com.jfinal.club.common.model.Document::PUBLISH_YES) <select
					name="doc.publish" class="publish-select">
					<option value="0" #(doc.publish?? == publishNo ? 'selected' : '' )>草稿</option>
					<option value="1" #(doc.publish?? == publishYes ? 'selected' : '' )>发布</option>
				</select> <input class="btn btn-primary" type="submit" value="提交" />
			</div>
		</form>

	</div>
	<!-- END OF jfa-content -->
</div>
<!-- END OF jfa-content-box -->

<style type="text/css">
.jfa-content label {
	line-height: 1;
	vertical-align: baseline;
	color: #23527c;
	font-size: 20px;
	font-weight: normal;
	margin-bottom: 8px;;
}

.publish-select {
	position: relative;
	top: 3px;
	right: 30px;
	padding: 2px 8px;
	font-size: 18px;
}
</style>

<script type="text/javascript">
	$(document).ready(function() {
		initUeditor();

		// 上传时在 url 中用问号挂参的方式添加额外的参数 uploadType，用于分类管理图片
		env.ueditor.ready(function() {
			env.ueditor.execCommand('serverparam', {
				'uploadType': 'document'
			});
		});

		$("#myArticleForm").ajaxForm({
			dataType: "json"
			, beforeSubmit: function(formData, jqForm, options) {
				env.ueditor.sync();  // 同步一下 ueditor 中的数据到表单域
			}
			, success: function(ret) {
				if (ret.state == "ok") {
					location.href = "/admin/doc";
				} else {
					showFailMsg(ret.msg);
				}
			}
			, error: function(ret) {alert(ret.statusText);}
			, complete: function(ret) {} 	      // 无论是 success 还是 error，最终都会被回调
		});
	});
</script>

#end
